package org.jeecg.modules.article.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.article.entity.Article;
import org.jeecg.modules.article.vo.RotationVO;
import org.jeecg.modules.collectarticles.entity.PhilCollectionArticles;
import org.jeecg.modules.collectarticles.vo.CollectsVO;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: 文章
 * @Author: jeecg-boot
 * @Date:   2020-10-14
 * @Version: V1.0
 */
@Mapper
@Repository
public interface ArticleMapper extends BaseMapper<Article> {
   /**
    * TODO: 获取阅读人数
    *
    *
    * @author Wanghaizhu
    * @param articleId
    * @return int
    */
   int readingNum(@Param("articleId") String articleId);
   /**
    * TODO: 更新阅读人数
    *
    *
    * @author Wanghaizhu
    * @param articleId
    * @param num
    * @return int
    */
   int updateReadingNum(@Param("articleId") String articleId,@Param("num") Integer num);
   /**
    * TODO: 获取首页文章
    *
    *
    * @author Wanghaizhu
    * @param page 分页
    * @return java.util.List<org.jeecg.modules.demo.phil.entity.Article>
    */
   List<Article> queryListByHomePageIsTrue(Page<Article> page);

   /**
    * TODO: 根据文章id获取文章标题
    *
    *
    * @author ZhangHaoyu
    * @param articleId 文章id
    * @return java.lang.String
    */
   @Select("select `article_title` from article where id = #{id}")
    String getArticleTitleById(@Param("id") String articleId);

   /**
    * TODO: 通过文章收藏集合查询文章信息
    *
    *
    * @author ZhangHaoyu
    * @param page 分页
    * @param arrays 用户收藏的id们
    * @return java.util.List<org.jeecg.modules.phil.entity.Article>
    */
    List<CollectsVO> queryArticleCollectByIds( @Param("list") List<PhilCollectionArticles> arrays);


    /**
     * TODO: 获取轮播图
     *
     *
     * @author ZhangHaoyu
     * @return java.util.List<org.jeecg.modules.phil.entity.Article>
     */
    @Select("select id,article_image from article where article_top_rotation = 1")
    List<RotationVO> getTopRotation();

    /**
     * TODO: 根据栏目获取对应栏目文章
     *
     *
     * @author ZhangHaoyu
     * @param page
     * @param columnName 栏目名称
     * @return java.util.List<org.jeecg.modules.article.entity.Article>
     */
    @Select("select id,article_title,article_author,create_time,article_column_top,article_image from article where article_column = #{columnName} order by article_column_top desc,create_time desc")
    List<Article> queryArticleByColumn(Page<Article> page, @Param("columnName") String columnName);

    /**
     * TODO: 根据ids获取文章的某些信息
     *
     *
     * @author ZhangHaoyu
     * @param list
     * @return java.util.List<org.jeecg.modules.article.entity.Article>
     */
    List<Article> queryArticleByIds(@Param("list") List<String> list);
}
